$(function(){
	$('#nowTime').createTime({format:'yyyy/MM/dd EEE HH:mm:ss'});
	
});

function arrive(enumber){
	if($(':input[name=enumber][value="'+enumber+'"]').length != 0) return;
	var iframe =  createFrame('iframe',contextpath+'/car/arrive.do?placeId='+placeId+'&car.enumber='+enumber, 800, 550);
	$('#showContent').empty().html(iframe);
	$.post(contextpath+'/car/findCar.do',{'car.enumber':enumber}, function(data){
		if(typeof data == 'string')data = eval('('+ data +')');
		if(data.returnCode) return;
		
		var innerHtml = '<div class="iterm">';
		innerHtml += '<div class="r-iterm-name">'+data.driver+'</div>';
		innerHtml += '<div class="r-iterm-num">'+data.carNum+'</div>';
		innerHtml += '<input type="hidden" name="enumber" value="'+ data.enumber +'"/>';
		innerHtml += '</div>';
		$('.left.driver').append(innerHtml);
	});
	
	
}

function leave(enumber){
	var iframe =  createFrame('iframe',contextpath+'/car/leave.do?placeId='+placeId+'&car.enumber='+enumber, 800, 550);
	$('#showContent').html(iframe);
	$(':input[name=enumber][value="'+enumber+'"]').parent().addClass('leave');
}

function createFrame(id,url, width, height){
	var iframe = '<iframe id="'+id+'" scrolling="auto" frameborder="0" src="'+url+'" style="width:'+width+'px;height:'+height+'px;"></iframe>';
	return iframe;
}

function createWindow(id, width, height, title, iframe){
	var content = "<div class='title'>"+title+"<span class='close' onclick='javascript:$(this).parent().parent().remove();'>关闭</span></div>";
	content += "<div class='content'><div id='load' align='center'>loading</div>"+iframe+"</div>";
	$('<div/>',{
		id: id,
		'class': 'window',
		width: width,
		height: height,
		html:content
	}).appendTo('.main');
	
	$('#iframe').bind('load',function(){
		$("#load").remove();
		$('#iframe').show();
	});
}

function findArriveCar(){
	var num = parseInt($('#arriveCarNum').text());
	if(num == 0) return;
	window.location.href = contextpath+'/car/findArrive.do?placeId='+placeId;
	//var iframe =  createFrame('iframe',contextpath+'/car/findArrive.do?placeId='+placeId, 980, 700);
	//$('#window').remove();
	//createWindow('window',980,700,'有新车到达',iframe);
}